local newt = reload("newt")
local type = type
local conver = {
    ['boolean'] = "bVal",
    ['number'] = "dVal",
    ['string'] = "sVal",
    ['table'] = "hash",
}

---lua table转成 proto 可以组织的
local function localf(t)
    local ret = newt()
    local hash = newt()
    ret.hash = hash
    for k, v in pairs(t) do
        local sk = tostring(k) or k
        local t = type(v)
        local c = conver[t]
        if t == "table" then
            local n = localf(v)
            hash[sk] = n
            n.name = c
        else
            local n = newt()
            hash[sk] = n
            n[c] = v
            n.name = c
        end
    end
    return ret
end

return localf
